import { createRouter, createWebHashHistory, RouteRecordRaw } from 'vue-router'
const routes: Array<RouteRecordRaw> = [
  {
    path: '/login',
    name: 'login',
    meta: {
      noAuth: true
    },
    component: () => import('@views/signin/Signin.vue')
  },
  {
    path: '/scene',
    name: 'scene',
    component: () => import('@views/entmall/LiveScene.vue')
  },
  {
    path: '/',
    name: 'home',
    redirect: 'dashboard',
    component: () => import('@views/layout/Layout.vue'),
    children: [{
      path: '/dashboard',
      name: 'dashboard',
      component: () => import('@views/Dashboard/index.vue')
    },{
      path: '/promotion/activity',
      name: '/promotion/activity',
      component: () => import('@views/promotion/Activity.vue')
    },{
      path: '/promotion/createAct',
      name: '/promotion/createAct',
      meta: {
        type: "create"
      },
      component: () => import('@views/promotion/CreateAct.vue')
    },
    {
      path: '/promotion/editAct',
      name: '/promotion/editAct',
      meta: {
        type: "edit"
      },
      component: () => import('@views/promotion/CreateAct.vue')
    },{
      path: '/promotion/bill',
      name: '/promotion/bill',
      component: () => import('@views/promotion/Bill.vue')
    }, {
      path: '/promotion/mediaReport',
      name: '/promotion/mediaReport',
      component: () => import('@views/promotion/MediaReport.vue')
    }, {
      path: '/promotion/overview',
      name: '/promotion/overview',
      component: () => import('@views/promotion/Overview.vue')
    },{
      path: '/promotion/rechargeRecord',
      name: '/promotion/rechargeRecord',
      component: () => import('@views/promotion/RechargeRecord.vue')
    },{
      path: '/promotion/recharge',
      name: '/promotion/recharge',
      component: () => import('@views/promotion/Recharge.vue')
    },{
      path: '/live',
      name: 'live',
      component: () => import('@views/entmall/Live.vue')
    }, {
      path: '/live/stat',
      name: '/live/stat',
      component: () => import('@views/entmall/LiveStat.vue')
    },{
      path: '/live/cart',
      name: 'cart',
      component: () => import('@views/entmall/Cart.vue')
    }, {
      path: '/live/order',
      name: 'order',
      component: () => import('@views/entmall/Order.vue')
    }, {
      path: '/live/goods',
      name: 'goods',
      component: () => import('@views/entmall/Goods.vue')
    }, {
      path: '/live/category',
      name: 'category',
      component: () => import('@views/entmall/Category.vue')
    }, {
      path: '/live/website',
      name: 'website',
      component: () => import('@views/entmall/Website.vue')
    }, {
      path: '/marketing/rule',
      name: 'rule',
      component: () => import('@views/marketing/Rule.vue')
    }, {
      path: '/marketing/gold',
      name: 'gold',
      component: () => import('@views/marketing/Gold.vue')
    }, {
      path: '/marketing/code',
      name: 'code',
      component: () => import('@views/marketing/Code.vue')
    }, {
      path: '/marketing/black',
      name: 'black',
      component: () => import('@views/marketing/Black.vue')
    }, {
      path: '/marketing/goshop',
      name: 'goshop',
      component: () => import('@views/marketing/Goshop.vue')
    }, {
      path: '/user',
      name: 'user',
      component: () => import('@views/user/User.vue')
    }, {
      path: '/user/info',
      name: 'userInfo',
      component: () => import('@views/user/UserInfo.vue')
    },{
      path: '/user/subs',
      name: 'subs',
      component: () => import('@views/user/Subs.vue')
    }, {
      path: '/user/group',
      name: 'group',
      component: () => import('@views/user/Group.vue')
    }, {
      path: '/user/message',
      name: 'message',
      component: () => import('@views/user/Message.vue')
    }, {
      path: '/report/order',
      name: 'orderReport',
      component: () => import('@views/report/OrderReport.vue')
    }, {
      path: '/report/sale',
      name: 'saleReport',
      component: () => import('@views/report/SaleReport.vue')
    }, {
      path: '/report/user',
      name: 'userReport',
      component: () => import('@views/report/UserReport.vue')
    }, {
      path: '/report/cart',
      name: 'cartReport',
      component: () => import('@views/report/CartReport.vue')
    }, {
      path: '/report/live',
      name: 'liveReport',
      component: () => import('@views/report/LiveReport.vue')
    }, {
      path: '/report/pay',
      name: 'payReport',
      component: () => import('@views/report/PayReport.vue')
    }, {
      path: '/setting/account',
      name: 'account',
      component: () => import('@views/setting/Account.vue')
    }, {
      path: '/setting/payment',
      name: 'payment',
      component: () => import('@views/setting/Payment.vue')
    }, {
      path: '/setting/shipping',
      name: 'shipping',
      component: () => import('@views/setting/Shipping.vue')
    }, {
      path: '/setting/morecart',
      name: 'morecart',
      component: () => import('@views/setting/Morecart.vue')
    }, {
      path: '/setting/emall',
      name: 'emall',
      component: () => import('@views/setting/Emall.vue')
    }, {
      path: '/setting/messageAuto',
      name: 'messageAuto',
      component: () => import('@views/setting/message/Auto.vue')
    }, {
      path: '/setting/messageStart',
      name: 'messageStart',
      component: () => import('@views/setting/message/Start.vue')
    }, {
      path: '/setting/messageKey',
      name: 'messageKey',
      component: () => import('@views/setting/message/Key.vue')
    }, {
      path: '/setting/createKey',
      name: 'createKey',
      meta: {
        type: "create"
      },
      component: () => import('@views/setting/message/CreateKey.vue')
    }, {
      path: '/setting/editKey',
      name: 'editKey',
      meta: {
        type: "edit"
      },
      component: () => import('@views/setting/message/CreateKey.vue')
    },{
      path: '/setting/messageKf',
      name: 'messageKf',
      component: () => import('@views/setting/message/Kf.vue')
    }, {
      path: '/setting/messageKf/dialog',
      name: 'messageKfDialog',
      component: () => import('@views/setting/message/Dialog.vue')
    },{
      path: '/setting/messageCont',
      name: 'messageCont',
      component: () => import('@views/setting/message/Msg.vue')
    }, {
      path: '/setting/messageMenu',
      name: 'messageMenu',
      component: () => import('@views/setting/message/Menu.vue')
    }]
  },
  {
    path: '/404',
    name: '404',
    component: () => import('@views/notfound/index.vue')
  },
]

const router = createRouter({
  history: createWebHashHistory(),
  routes
})
//路由前置守卫，验证用户身份，检查权限
//to即将进入目标路由对象，包含路径，参数
//from 当前导航正要离开的路由对象，包含了当前的路由信息
//next函数，用于控制导航行为，他可以接收一个参数，
// router.beforeEach((to, from, next) => {
//   if(to.meta.noAuth||localStorage.token){
//   next()
// }else {
//   router.push('/login')
// }
// })
export default router
